package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.alibaba.domain.CommonResult;
import com.atguigu.springcloud.alibaba.domain.Order;
import com.atguigu.springcloud.alibaba.service.OrderService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/order/create")
    public CommonResult<Order> creatOrder(@RequestBody Order order) {
        orderService.createOrder(order);
        return new CommonResult<Order>(200, "订单创建成功");
    }

    @GetMapping("/order/getById/{id}")
    public CommonResult<Order> getById(@PathVariable("id") Integer id) {
        Order order = orderService.getById(id);
        return new CommonResult<Order>(200, "查询成功",order);
    }
}
